package GUI;
/**
 * Select a student so the principle can view his academic data
 */
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JButton;


import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Vector;


public class PrincipleVpdSelStudent extends JPanel {

	private JLabel lblPrincipleViewData = null;
	private JLabel lblSelectStudent = null;
	private JComboBox cBSelStudent = null;
	private JButton btnNext = null;
	
	public Login myLoginFrame = null;
	public static Dimension defaultDim=null;
	public UserPrinciple user=null;;
	public PrincipleMainMenu prmn = null;
	
	private String selStudent = null;
	private PrincipleVpdSelYearnSem selYearnSemScreen=null;
	
	
	
	 
	
	public JComboBox getSelStudentCb(PrincipleMainMenu prmn)
	{
		int i;
		Vector <String> student = new Vector<String>();
		
		for(i=0;i<prmn.user.StudentsData.size();i++)
		{
			
			System.out.println("Selected Class " +prmn.user.getSelClass() );
			System.out.println("Student Class " +prmn.user.StudentsData.get(i).ClassId );
			
			if(prmn.user.StudentsData.get(i).ClassId==(prmn.user.getSelClass())&&(prmn.user.StudentsData.get(i).ClassId!=null))
					{
				
				student.add(prmn.user.StudentsData.get(i).FirstName+" "+prmn.user.StudentsData.get(i).LastName+" "+prmn.user.StudentsData.get(i).Sid);
					}
		}
		
		if(cBSelStudent==null)
		{
			cBSelStudent = new JComboBox(student);
			cBSelStudent.addActionListener(new ActionListener() {
			 	public void actionPerformed(ActionEvent arg0) {
			 		selStudent=cBSelStudent.getSelectedItem().toString();
			 		System.out.println(selStudent);
			 		
			 	}
			 });
			cBSelStudent.setBounds(224, 84, 168, 20);
				
		}
		return cBSelStudent;
	}
	
	
	
	public JButton getNexBtn(final PrincipleMainMenu prmn)
	{
		if(btnNext==null)
		{
			 btnNext = new JButton("Next");
			 btnNext.addActionListener(new ActionListener() {
			 	public void actionPerformed(ActionEvent e) {
			 		prmn.user.setSelStudent(selStudent);
			 		selYearnSemScreen=null;
			 		selYearnSemScreen = prmn.getSelYearNSemScrn();
			 		prmn.setContentPane(selYearnSemScreen);
			 	}
			 });
				btnNext.setBounds(561, 309, 89, 23);
		}
		
		return btnNext;
	}
	
	
	private void initialize(PrincipleMainMenu prmn)
	{
		
		 setLayout(null);
			
		 lblPrincipleViewData = new JLabel("Principle view data");
		 lblPrincipleViewData.setBounds(397, 0, 89, 14);
		add(lblPrincipleViewData);
		
		lblSelectStudent = new JLabel("Select Class:");
		lblSelectStudent.setBounds(107, 87, 61, 14);
		add(lblSelectStudent);
		add(getSelStudentCb(prmn));
		add(getNexBtn(prmn));
		
	}

	
	public PrincipleVpdSelStudent(PrincipleMainMenu prmn) {
		super();
		initialize(prmn);
		
	}
}

